// custom-tab-bar/index.js
import {storeBindingsBehavior} from "mobx-miniprogram-bindings"
import {store} from "../store/store"
Component({
  data: {
  },
  behaviors:[storeBindingsBehavior],
  storeBindings:{
    store,
    fields:{
      activePage:"activePage"
    },
    actions:{
      updateActivePage:"updateActivePage"
    }
  },
  methods:{
    onChange(event) {
      // event.detail 的值为当前选中项的索引
      this.updateActivePage(event.detail)
      switch(event.detail){
        case 0:{
          wx.switchTab({
            url: '/pages/index/index'
          })
          break;
        };
        case 1:{
          wx.switchTab({
            url: '/pages/video_page/video_page'
          })
          break;
        };
        case 2:{
          wx.switchTab({
            url: '/pages/file_page/file_page'
          })
          break;
        };
        case 3:{
          wx.switchTab({
            url: '/pages/user_page/user_page'
          })
          break;
        };
      }
    }
  }

})
